//
//  Message.m
//  HuaZiChatDemo
//
//  Created by huazi on 15-4-2.
//  Copyright (c) 2015年 huifu. All rights reserved.
//

#import "Message.h"
#import "NSDictionary+NilToChar.h"
//@property (nonatomic) MessageType type;
//@property (nonatomic) MessageSender sender;
//@property (nonatomic) MessageStatus status;
//@property (strong, nonatomic)NSString *oprId;    //消息持有者
//@property (strong, nonatomic)NSString *content;  //text 类型文本内容
//@property (strong, nonatomic)NSString *name;     //好友名称
//@property (strong, nonatomic)NSString *urlMessage;  //消息下载地址 语音或大图的下载地址
//@property (strong, nonatomic)NSString *urlSmallPic; //只有当为图片时，小的图片地址
//@property (nonatomic)NSInteger timeLength;
//@property (strong, nonatomic)NSString *sendTime;    //消息的发送或接收时间
//@property (strong, nonatomic)NSString *filePath;
//@property (nonatomic)BOOL isReaded;
//@property (nonatomic)BOOL isPlayed;    //仅当消息为音频的情况下，是否已播放过该音频
@implementation Message
- (instancetype)initWithReceiveDic:(NSDictionary *)dic {
    if (self =[super init]) {
        
    }
    return self;
}
- (instancetype)initWithSendDic:(NSDictionary *)dic AndMessageType:(MessageType)type{
    if (self =[super init]) {
        _type =type;
        switch (type) {
            case MessageTypeText:
                _content =[dic objectForKey:@"content"];
                
                break;
            case MessageTypeVoice:
                _filePath =[dic objectForKey:@"filePath"];
                break;
            case MessageTypePhoto:
                _filePath =[dic objectForKey:@"filePath"];
                break;
            default:
                break;
        }
        _oprId =[dic objectForKey:@"oprId"];
        _user_Id =[dic objectForKey:@"user_Id"];
        _name =[dic objectForKey:@"name"];
        _time =[dic objectForKey:@"time"];
        _isPlayed =YES;
        _isReaded =YES;
        _status =MessageStatusSending;
        _sender =MessageSenderSelf;
        
    }
    return self;
}
- (instancetype)initWithDatabaseDic:(NSDictionary *)dic{
    if (self =[super init]) {
        
    }
    return self;
}
@end
